package com.eliteams.quick4j.core.util;

import org.apache.commons.codec.binary.Base64;

/**
 * @author wuchaofei
 * @date 2016/4/20
 */
public class Base64Util {
    public Base64Util() {
    }

    public static byte[] decode(byte[] bytes) {
        try {
            return Base64.decodeBase64(bytes);
        } catch (Exception var2) {
            return null;
        }
    }

    public static String decode(String str) {
        if(str != null && !str.isEmpty()) {
            byte[] bytes = decode((byte[])str.getBytes());
            return String.valueOf(bytes);
        } else {
            return "";
        }
    }

    public static String encode(byte[] bytes) {
        return new String(Base64.encodeBase64(bytes));
    }

    public static String encode(String str) {
        try {
            return encode((byte[])str.getBytes());
        } catch (Exception var2) {
            return null;
        }
    }
}